package tij4.ch17;

import java.util.concurrent.TimeUnit;

public class SimpleDeamons implements Runnable
{

	@Override
	public void run()
	{
		try
		{
			
				TimeUnit.MILLISECONDS.sleep(100);
				System.out.println(Thread.currentThread() + " " + this);
			
		}
		catch (InterruptedException e)
		{
			System.out.println("sleep() interrupted");
		}
	
	}
	
	
	public static void main(String[] args) throws InterruptedException
	{
		for (int i = 0; i < 10; i++)
		{
			Thread daemon = new Thread(new SimpleDeamons());
			daemon.setDaemon(true);
			daemon.start();
		}
		
			System.out.println("All deamons are running");
			TimeUnit.MILLISECONDS.sleep(175);
	}
	
}
